package com.googlecode.connectlet.crypto.cipher.mode;

public class Pkcs5PaddingDecipherorFinal implements FinalBlock {
	private byte[] padding;

	public Pkcs5PaddingDecipherorFinal(byte[] padding) {
		this.padding = padding;
	}

	@Override
	public int doFinal(byte[] output, int outputOffset) {
		int nPadding = padding.length - padding[padding.length - 1];
		for (int i = 0; i < nPadding; i ++) {
			output[outputOffset + i] = padding[i];
		}
		return nPadding;
	}
}